﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TooltracePC
{
    public partial class frmSetIN : Form
    {
        dgv dgvObject = new dgv();
        private static string _fileName = "";
        //private static int _fileStatus = 0;

        public frmSetIN()
        {
            InitializeComponent();
        }

        private void frmSetIN_Load(object sender, EventArgs e)
        {
            _fileName = dgvObject.getSelectedFile().Trim();
            if (_fileName == "")
            {
                MessageBox.Show("请先选择记录", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return;
            }

            dbUser Userdb = new dbUser();
            DataTable dtU = new DataTable();
            dtU = Userdb.getAll();

            for (int i = 0; i < dtU.Rows.Count; i++)
            {
                cbMan.Items.Add(dtU.Rows[i]["UserName"].ToString());
            }

        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string strMan = "";
            string strDate = "";

            strMan = cbMan.Text;
            strDate = dpSetInDate.Text.ToString();

            if (string.IsNullOrEmpty(strMan) || string.IsNullOrEmpty(strDate))
            {
                MessageBox.Show("请输入操作人!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            dbSync syncDataDb = new dbSync();
            //删除多余记录
            syncDataDb.delSyncDataMore(_fileName);
            //更新未完成的记录
            syncDataDb.mtUpSyncData(_fileName, strMan, strDate);

            DataTable dt = new DataTable();
            dt = syncDataDb.getSyncDataByName(_fileName);
            dgvObject.setDataSource(dt);
            this.Close();

        }
    }
}
